-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssh module refactoring separate auth/shell checks #331
base: main
Are you sure you want to change the base?
Conversation
525fbfe
to
a0b39c9
Compare
deaabbb
to
d17522e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the PR!
Please describe briefly (in the PR description) what has been done and why, so we know what this PR aims to achieve without diving into past issues etc.
If possible please also provide example output screenshots
except AuthenticationException: | ||
self.logger.fail(f"{username}:{process_secret(password)}") | ||
except SSHException as e: | ||
if "Invalid key" in str(e): | ||
self.logger.fail(f"{username}:{process_secret(password)} Could not decrypt private key, error: {e}") | ||
if "Error reading SSH protocol banner" in str(e): | ||
self.logger.error(f"Internal Paramiko error for {username}:{process_secret(password)}, {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please preserve the current Exception handling, as with this we can catch some weird paramiko issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those exception are already handled in create_conn_obj() However, I could add the logger calls to keep the previous behavior.
Edit: actually, I didn't remembered well, there are 2 connections, a first one to check that the service is present with conn_obj() which as exception handling. A second one with plaintext_login() for which I added handle_connection_failure() to handle all kind of exception
shell_access = True | ||
def connect_with_key(self, username, password, key_content): | ||
self.logger.debug(f"Logging {self.host} with username: {self.username}, key: {self.args.key_file}") | ||
pkey = paramiko.RSAKey.from_private_key(StringIO(key_content)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is with all the other key types? This should not be limited to RSA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good catch this is a last PR modification mistake, I'll fix that
While we are at it we should probably also catch the timeout error in #358. |
This pull request aims to refactor the code to make it more readable but also to properly separate the code that can be linked to authentication from the code linked to the test concerning the shell obtained